#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QTcpServer>
#include <QLabel>
#include <QTcpSocket>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QTextBrowser>
#include <QComboBox>
#include <QSpinBox>
#include <QLineEdit>
#include <QList>
#include <QNetworkInterface>

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private:
    void getLocalHostIP();//获取本地所有ip

    void connectSigToSlots();//信号与槽的连接

private slots:
    //客户端连接槽函数
    void clientConnected();
    //开始监听槽函数
    void startListen();
    //停止监听
    void stopListen();
    //清除文本框中的内容
    void clearTextBrower();
    //收到消息
    void receiveMessage();
    //发送消息
    void sendMessage();
    //连接状态改变槽函数
    void socketStateChanged(QAbstractSocket::SocketState state);

private:
    QTcpServer* tcpServe;
    QTcpSocket* tcpSocket;
    QPushButton* button[4];
    QLabel* label[2];
    QWidget* hwidget[3];
    QHBoxLayout* hLayout[4];
    QVBoxLayout* vLayout;
    QTextBrowser* browser;
    QComboBox* comboBox;
    QSpinBox* spinBox;
    QLineEdit* lineEdit;
    QList<QHostAddress> ipList;

};
#endif // WIDGET_H
